package com.yf.interceptor;

import com.yf.action.AuthAction;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.lang.Nullable;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @ClassName AuthInterceptor
 * @Description TODO
 * @Author yf
 * @Date 2018/10/15 14:51
 * @Version 1.0
 */
public class AuthInterceptor implements HandlerInterceptor {
    private static final Logger LOGGER= LoggerFactory.getLogger(AuthInterceptor.class);
    /**
     * 请求处理前被调用（true 继续执行；false 中断）
     */
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        LOGGER.info("preHandle 执行了");
        return true;
    }

    /**
     * 请求处理后调用
     */
    @Override
    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, @Nullable ModelAndView modelAndView) throws Exception {
        LOGGER.info("postHandle 执行了");
    }

    /**
     * 在视图渲染之后调用
     */
    @Override
    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, @Nullable Exception ex) throws Exception {
        LOGGER.info("afterCompletion 执行了");
    }
}
